package com.lei.baweiliao.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.lei.baweiliao.bean.UserBean;
import com.lei.baweiliao.db.DaoMaster;
import com.lei.baweiliao.db.DaoSession;

/**
 * @ProjectName : BaweiLiao
 * @Author : 雷金泷
 * @Time : 2021/1/14 11:25
 * @Description : 文件描述
 */
public class GreenDaoUtils {
    private static GreenDaoUtils instance = new GreenDaoUtils();
    private static Context mContext;
    private static DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(mContext,"user_ku");

    public static GreenDaoUtils getInstance(Context context){
        mContext = context;
        return instance;
    }
    public DaoSession newsession(){
        DaoMaster daoMaster = new DaoMaster(devOpenHelper.getWritableDatabase());
        return daoMaster.newSession();
    }

    public void add(UserBean bean){
        newsession().insert(bean);
    }
    public UserBean query(UserBean bean,String name){
        return newsession().load(UserBean.class,name);
    }
    public void delete(UserBean bean){
        newsession().delete(bean);
    }

    //TODO 改



}
